<link rel="stylesheet" href="/stylesheets/user_editor.css">
<script src="/javascripts/usreditor.js"></script>
<h2>用户管理</h2>
<h4>新建用户</h4>
<form>
    <div class="form-row">
        <div class="form-group col">
            <label>用户名</label>
            <input id="new_user" type="text" class="form-control"/>
        </div>
        <div class="form-group col">
            <label>密码</label>
            <input id="new_pwd" type="text" class="form-control"/>
        </div>
    </div>
    <div class="form-group">
        <a href="javascript:register()" class="btn btn-success">创建</i></a>
    </div>
</form>

<h4>现有用户</h4>
<form>
    <table class="form-group"><tbody>
        <tr>
            <th>用户名</th>
            <th>密码</th>
            <th>操作</th>
        </tr>
        <% if(userlist!=undefined) for(usr in userlist) { %>
            <tr id="tr-<%=usr%>">
                <td><span><%= usr %></span></td>
                <td>
                    <div id="pwd1-<%=usr%>">
                        <span>********  </span>
                        <% if(usr!='admin') {%>
                        <a href="javascript:swpanel('<%=usr%>')" class="btn btn-primary btn-sm">修改</i></a>
                        <%}%>
                    </div>
                    <% if(usr!='admin') {%>
                    <div id="pwd2-<%=usr%>" style="display:none">
                        <input class="form-control-sm" id="pwd-<%=usr%>" type="text" class="form-control"/>
                        <a href="javascript:setpwd('<%=usr%>')" class="btn btn-success btn-sm">保存</i></a>
                    </div>
                    <%}%>
                </td>
                <td>
                    <% if(usr!='admin') {%>
                    <a href="javascript:unreg('<%=usr%>')" class="btn btn-danger btn-sm">删除</i></a>
                    <%}else{%>
                    <span>(无权限)</span>
                    <%}%>
                </td>
            </tr>
        <% } %>
    </tbody></table>
</form>
<p id="te_tip" style="display:none"></p>